/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kasus1pendaftaranyudisium;

import DataBase.OraConnection;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Sony
 */
public class PengendaliPemeriksaanYudisium {

       public static void validasiDataYudisium(Mahasiswa mhs) {
        Connection conn = OraConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "ria");
        Statement statement = null;
        try {
            statement = conn.createStatement();
            String sql = "update yudisium set daftar_nilai='"+mhs.getDaftar_nilai()+
                    "',naskah_ta='"+mhs.getNaskah_ta()+
                    "',bebaspinjam_lab='"+mhs.getBebaspinjam_lab()+
                    "',bebaspinjam_dosen='"+mhs.getBebaspinjam_dosen()+
                    "',bukti_kp='"+mhs.getBukti_kp()+
                    "',toelf_tkbi='"+mhs.getToelf_tkbi()+
                    "',ket_kkl='"+mhs.getKet_kkl()+
                    "',file_ket='"+mhs.getFile_ket()+
                    "',keterangan='"+mhs.getKeterngan()+"'"+
                    " where nim='"+mhs.getNim()+"'";
                  statement.executeUpdate(sql);
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPendaftaranYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        JOptionPane.showMessageDialog(null, "Berhasil di update");
    }

      public static void periksaDataYudisium(Cek cek) {
        PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA = new ArrayList<Mahasiswa>();
        Connection conn = OraConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "ria");
        java.sql.Statement statement = null;
        try {
            statement = conn.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        String sqQ = "select * from yudisium where nim = '" + cek.getNim() + "'";
        ResultSet result = null;
        try {
            result = statement.executeQuery(sqQ);
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            while (result.next()) {
                Mahasiswa mhs = new Mahasiswa();
                mhs.setNama(result.getString("nama"));
                mhs.setNim(result.getString("nim"));
                mhs.setNoHp(result.getString("nomor_hp"));
                mhs.setProdi(result.getString("prodi"));
                mhs.setBulan(result.getString("bulan_yudisium"));
                mhs.setHari(result.getString("hari_yudisium"));
                mhs.setTanggal(result.getInt("tanggal_yudisium"));
                mhs.setDaftar_nilai(result.getString("daftar_nilai"));
                mhs.setNaskah_ta(result.getString("naskah_TA"));
                mhs.setBebaspinjam_lab(result.getString("bebaspinjam_lab"));
                mhs.setBebaspinjam_dosen(result.getString("bebaspinjam_dosen"));
                mhs.setBukti_kp(result.getString("bukti_kp"));
                mhs.setToelf_tkbi(result.getString("toelf_TKBI"));
                mhs.setKet_kkl(result.getString("ket_KKL"));
                mhs.setFile_ket(result.getString("file_ket"));
                      mhs.setKeterngan(result.getString("keterangan"));
                PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA.add(mhs);
            }
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            conn.close();
        } catch (SQLException ex) {
        }
    }

     public static void lihatTabelYudisium(Sekretariat sekre) {
        PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA = new ArrayList<Mahasiswa>();
        Connection conn = OraConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "ria");
        java.sql.Statement statement = null;
        try {
            statement = conn.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        String sqQ = "select * from yudisium where bulan_yudisium='" + sekre.getBulan() + "'and tanggal_yudisium between " + sekre.getTglawal() + " and " + sekre.getTglakhir() + "";
        ResultSet result = null;
        try {
            result = statement.executeQuery(sqQ);
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            while (result.next()) {
                Mahasiswa mhs = new Mahasiswa();
                mhs.setNama(result.getString("nama"));
                mhs.setNim(result.getString("nim"));
                mhs.setNoHp(result.getString("nomor_hp"));
                mhs.setProdi(result.getString("prodi"));
                mhs.setBulan(result.getString("bulan_yudisium"));
                mhs.setHari(result.getString("hari_yudisium"));
                mhs.setTanggal(result.getInt("tanggal_yudisium"));
                mhs.setDaftar_nilai(result.getString("daftar_nilai"));
                mhs.setNaskah_ta(result.getString("naskah_TA"));
                mhs.setBebaspinjam_lab(result.getString("bebaspinjam_lab"));
                mhs.setBebaspinjam_dosen(result.getString("bebaspinjam_dosen"));
                mhs.setBukti_kp(result.getString("bukti_kp"));
                mhs.setToelf_tkbi(result.getString("toelf_TKBI"));
                mhs.setKet_kkl(result.getString("ket_KKL"));
                mhs.setFile_ket(result.getString("file_ket"));
                      mhs.setKeterngan(result.getString("keterangan"));
                PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA.add(mhs);
            }
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            conn.close();
        } catch (SQLException ex) {
        }
    }
}
